home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / rt.jar / sun / print / PrintJob2D.class (.txt) < prev    next >
Encoding:
Java Class File  |  2006-11-29  |  20.8 KB  |  701 lines

  1. package sun.print;
  2.  
  3. import java.awt.Dimension;
  4. import java.awt.Frame;
  5. import java.awt.Graphics;
  6. import java.awt.Graphics2D;
  7. import java.awt.JobAttributes;
  8. import java.awt.PageAttributes;
  9. import java.awt.PrintJob;
  10. import java.awt.JobAttributes.DefaultSelectionType;
  11. import java.awt.JobAttributes.DestinationType;
  12. import java.awt.JobAttributes.DialogType;
  13. import java.awt.JobAttributes.MultipleDocumentHandlingType;
  14. import java.awt.JobAttributes.SidesType;
  15. import java.awt.PageAttributes.ColorType;
  16. import java.awt.PageAttributes.MediaType;
  17. import java.awt.PageAttributes.OrientationRequestedType;
  18. import java.awt.PageAttributes.OriginType;
  19. import java.awt.PageAttributes.PrintQualityType;
  20. import java.awt.print.PageFormat;
  21. import java.awt.print.Paper;
  22. import java.awt.print.Printable;
  23. import java.awt.print.PrinterException;
  24. import java.awt.print.PrinterJob;
  25. import java.io.File;
  26. import java.io.FilePermission;
  27. import java.io.IOException;
  28. import java.net.URI;
  29. import java.net.URISyntaxException;
  30. import java.util.Locale;
  31. import java.util.Properties;
  32. import javax.print.PrintService;
  33. import javax.print.attribute.HashPrintRequestAttributeSet;
  34. import javax.print.attribute.PrintRequestAttributeSet;
  35. import javax.print.attribute.standard.Chromaticity;
  36. import javax.print.attribute.standard.Copies;
  37. import javax.print.attribute.standard.Destination;
  38. import javax.print.attribute.standard.JobName;
  39. import javax.print.attribute.standard.Media;
  40. import javax.print.attribute.standard.MediaSize;
  41. import javax.print.attribute.standard.MediaSizeName;
  42. import javax.print.attribute.standard.OrientationRequested;
  43. import javax.print.attribute.standard.PageRanges;
  44. import javax.print.attribute.standard.PrintQuality;
  45. import javax.print.attribute.standard.SheetCollate;
  46. import javax.print.attribute.standard.Sides;
  47.  
  48. public class PrintJob2D extends PrintJob implements Printable, Runnable {
  49.    private static final PageAttributes.MediaType[] SIZES;
  50.    private static final MediaSizeName[] JAVAXSIZES;
  51.    private static final int[] WIDTHS;
  52.    private static final int[] LENGTHS;
  53.    private Frame frame;
  54.    private String docTitle = "";
  55.    private JobAttributes jobAttributes;
  56.    private PageAttributes pageAttributes;
  57.    private PrintRequestAttributeSet attributes;
  58.    private PrinterJob printerJob;
  59.    private PageFormat pageFormat;
  60.    private MessageQ graphicsToBeDrawn = new MessageQ(this, "tobedrawn");
  61.    private MessageQ graphicsDrawn = new MessageQ(this, "drawn");
  62.    private Graphics2D currentGraphics;
  63.    private int pageIndex = -1;
  64.    private static final String DEST_PROP = "awt.print.destination";
  65.    private static final String PRINTER = "printer";
  66.    private static final String FILE = "file";
  67.    private static final String PRINTER_PROP = "awt.print.printer";
  68.    private static final String FILENAME_PROP = "awt.print.fileName";
  69.    private static final String NUMCOPIES_PROP = "awt.print.numCopies";
  70.    private static final String OPTIONS_PROP = "awt.print.options";
  71.    private static final String ORIENT_PROP = "awt.print.orientation";
  72.    private static final String PORTRAIT = "portrait";
  73.    private static final String LANDSCAPE = "landscape";
  74.    private static final String PAPERSIZE_PROP = "awt.print.paperSize";
  75.    private static final String LETTER = "letter";
  76.    private static final String LEGAL = "legal";
  77.    private static final String EXECUTIVE = "executive";
  78.    // $FF: renamed from: A4 java.lang.String
  79.    private static final String field_0 = "a4";
  80.    private Properties props;
  81.    private String options = "";
  82.    private Thread printerJobThread;
  83.  
  84.    public PrintJob2D(Frame var1, String var2, Properties var3) {
  85.       this.props = var3;
  86.       this.jobAttributes = new JobAttributes();
  87.       this.pageAttributes = new PageAttributes();
  88.       this.translateInputProps();
  89.       this.initPrintJob2D(var1, var2, this.jobAttributes, this.pageAttributes);
  90.    }
  91.  
  92.    public PrintJob2D(Frame var1, String var2, JobAttributes var3, PageAttributes var4) {
  93.       this.initPrintJob2D(var1, var2, var3, var4);
  94.    }
  95.  
  96.    private void initPrintJob2D(Frame var1, String var2, JobAttributes var3, PageAttributes var4) {
  97.       SecurityManager var5 = System.getSecurityManager();
  98.       if (var5 != null) {
  99.          var5.checkPrintJobAccess();
  100.       }
  101.  
  102.       if (var1 != null || var3 != null && var3.getDialog() != DialogType.NATIVE) {
  103.          this.frame = var1;
  104.          this.docTitle = var2 == null ? "" : var2;
  105.          this.jobAttributes = var3 != null ? var3 : new JobAttributes();
  106.          this.pageAttributes = var4 != null ? var4 : new PageAttributes();
  107.          int[][] var6 = this.jobAttributes.getPageRanges();
  108.          int var7 = var6[0][0];
  109.          int var8 = var6[var6.length - 1][1];
  110.          this.jobAttributes.setPageRanges(new int[][]{{var7, var8}});
  111.          this.jobAttributes.setToPage(var8);
  112.          this.jobAttributes.setFromPage(var7);
  113.          int[] var9 = this.pageAttributes.getPrinterResolution();
  114.          if (var9[0] != var9[1]) {
  115.             throw new IllegalArgumentException("Differing cross feed and feed resolutions not supported.");
  116.          } else {
  117.             JobAttributes.DestinationType var10 = this.jobAttributes.getDestination();
  118.             if (var10 == DestinationType.FILE) {
  119.                this.throwPrintToFile();
  120.                String var11 = var3.getFileName();
  121.                if (var11 != null && var3.getDialog() == DialogType.NONE) {
  122.                   File var12 = new File(var11);
  123.  
  124.                   try {
  125.                      if (var12.createNewFile()) {
  126.                         var12.delete();
  127.                      }
  128.                   } catch (IOException var14) {
  129.                      throw new IllegalArgumentException("Cannot write to file:" + var11);
  130.                   } catch (SecurityException var15) {
  131.                   }
  132.  
  133.                   File var13 = var12.getParentFile();
  134.                   if (var12.exists() && (!var12.isFile() || !var12.canWrite()) || var13 != null && (!var13.exists() || var13.exists() && !var13.canWrite())) {
  135.                      throw new IllegalArgumentException("Cannot write to file:" + var11);
  136.                   }
  137.                }
  138.             }
  139.  
  140.          }
  141.       } else {
  142.          throw new NullPointerException("Frame must not be null");
  143.       }
  144.    }
  145.  
  146.    public boolean printDialog() {
  147.       boolean var1 = false;
  148.       this.printerJob = PrinterJob.getPrinterJob();
  149.       if (this.printerJob == null) {
  150.          return false;
  151.       } else {
  152.          JobAttributes.DialogType var2 = this.jobAttributes.getDialog();
  153.          PrintService var3 = this.printerJob.getPrintService();
  154.          if (var3 == null && var2 == DialogType.NONE) {
  155.             return false;
  156.          } else {
  157.             this.copyAttributes(var3);
  158.             JobAttributes.DefaultSelectionType var4 = this.jobAttributes.getDefaultSelection();
  159.             if (var4 == DefaultSelectionType.RANGE) {
  160.                this.attributes.add(SunPageSelection.RANGE);
  161.             } else if (var4 == DefaultSelectionType.SELECTION) {
  162.                this.attributes.add(SunPageSelection.SELECTION);
  163.             } else {
  164.                this.attributes.add(SunPageSelection.ALL);
  165.             }
  166.  
  167.             if (var2 == DialogType.NONE) {
  168.                var1 = true;
  169.             } else {
  170.                if (var2 == DialogType.NATIVE) {
  171.                   this.attributes.add(DialogTypeSelection.NATIVE);
  172.                } else {
  173.                   this.attributes.add(DialogTypeSelection.COMMON);
  174.                }
  175.  
  176.                if (var1 = this.printerJob.printDialog(this.attributes)) {
  177.                   if (var3 == null) {
  178.                      var3 = this.printerJob.getPrintService();
  179.                      if (var3 == null) {
  180.                         return false;
  181.                      }
  182.                   }
  183.  
  184.                   this.updateAttributes();
  185.                   this.translateOutputProps();
  186.                }
  187.             }
  188.  
  189.             if (var1) {
  190.                JobName var5 = (JobName)this.attributes.get(JobName.class);
  191.                if (var5 != null) {
  192.                   this.printerJob.setJobName(var5.toString());
  193.                }
  194.  
  195.                this.pageFormat = new PageFormat();
  196.                Media var6 = (Media)this.attributes.get(Media.class);
  197.                MediaSize var7 = null;
  198.                if (var6 != null && var6 instanceof MediaSizeName) {
  199.                   var7 = MediaSize.getMediaSizeForName((MediaSizeName)var6);
  200.                }
  201.  
  202.                Paper var8 = this.pageFormat.getPaper();
  203.                if (var7 != null) {
  204.                   var8.setSize((double)var7.getX(25400) * (double)72.0F, (double)var7.getY(25400) * (double)72.0F);
  205.                }
  206.  
  207.                if (this.pageAttributes.getOrigin() == OriginType.PRINTABLE) {
  208.                   var8.setImageableArea((double)18.0F, (double)18.0F, var8.getWidth() - (double)36.0F, var8.getHeight() - (double)36.0F);
  209.                } else {
  210.                   var8.setImageableArea((double)0.0F, (double)0.0F, var8.getWidth(), var8.getHeight());
  211.                }
  212.  
  213.                this.pageFormat.setPaper(var8);
  214.                OrientationRequested var9 = (OrientationRequested)this.attributes.get(OrientationRequested.class);
  215.                if (var9 != null && var9 == OrientationRequested.REVERSE_LANDSCAPE) {
  216.                   this.pageFormat.setOrientation(2);
  217.                } else if (var9 == OrientationRequested.LANDSCAPE) {
  218.                   this.pageFormat.setOrientation(0);
  219.                } else {
  220.                   this.pageFormat.setOrientation(1);
  221.                }
  222.  
  223.                this.jobAttributes.setPrinter(var3.getName());
  224.                this.printerJob.setPrintable(this, this.pageFormat);
  225.             }
  226.  
  227.             return var1;
  228.          }
  229.       }
  230.    }
  231.  
  232.    private void updateAttributes() {
  233.       Copies var1 = (Copies)this.attributes.get(Copies.class);
  234.       this.jobAttributes.setCopies(var1.getValue());
  235.       SunPageSelection var2 = (SunPageSelection)this.attributes.get(SunPageSelection.class);
  236.       if (var2 == SunPageSelection.RANGE) {
  237.          this.jobAttributes.setDefaultSelection(DefaultSelectionType.RANGE);
  238.       } else if (var2 == SunPageSelection.SELECTION) {
  239.          this.jobAttributes.setDefaultSelection(DefaultSelectionType.SELECTION);
  240.       } else {
  241.          this.jobAttributes.setDefaultSelection(DefaultSelectionType.ALL);
  242.       }
  243.  
  244.       Destination var3 = (Destination)this.attributes.get(Destination.class);
  245.       if (var3 != null) {
  246.          this.jobAttributes.setDestination(DestinationType.FILE);
  247.          this.jobAttributes.setFileName(var3.getURI().getPath());
  248.       } else {
  249.          this.jobAttributes.setDestination(DestinationType.PRINTER);
  250.       }
  251.  
  252.       PrintService var4 = this.printerJob.getPrintService();
  253.       if (var4 != null) {
  254.          this.jobAttributes.setPrinter(var4.getName());
  255.       }
  256.  
  257.       PageRanges var5 = (PageRanges)this.attributes.get(PageRanges.class);
  258.       int[][] var6 = var5.getMembers();
  259.       this.jobAttributes.setPageRanges(var6);
  260.       SheetCollate var7 = (SheetCollate)this.attributes.get(SheetCollate.class);
  261.       if (var7 == SheetCollate.COLLATED) {
  262.          this.jobAttributes.setMultipleDocumentHandling(MultipleDocumentHandlingType.SEPARATE_DOCUMENTS_COLLATED_COPIES);
  263.       } else {
  264.          this.jobAttributes.setMultipleDocumentHandling(MultipleDocumentHandlingType.SEPARATE_DOCUMENTS_UNCOLLATED_COPIES);
  265.       }
  266.  
  267.       Sides var8 = (Sides)this.attributes.get(Sides.class);
  268.       if (var8 == Sides.TWO_SIDED_LONG_EDGE) {
  269.          this.jobAttributes.setSides(SidesType.TWO_SIDED_LONG_EDGE);
  270.       } else if (var8 == Sides.TWO_SIDED_SHORT_EDGE) {
  271.          this.jobAttributes.setSides(SidesType.TWO_SIDED_SHORT_EDGE);
  272.       } else {
  273.          this.jobAttributes.setSides(SidesType.ONE_SIDED);
  274.       }
  275.  
  276.       Chromaticity var9 = (Chromaticity)this.attributes.get(Chromaticity.class);
  277.       if (var9 == Chromaticity.COLOR) {
  278.          this.pageAttributes.setColor(ColorType.COLOR);
  279.       } else {
  280.          this.pageAttributes.setColor(ColorType.MONOCHROME);
  281.       }
  282.  
  283.       OrientationRequested var10 = (OrientationRequested)this.attributes.get(OrientationRequested.class);
  284.       if (var10 == OrientationRequested.LANDSCAPE) {
  285.          this.pageAttributes.setOrientationRequested(OrientationRequestedType.LANDSCAPE);
  286.       } else {
  287.          this.pageAttributes.setOrientationRequested(OrientationRequestedType.PORTRAIT);
  288.       }
  289.  
  290.       PrintQuality var11 = (PrintQuality)this.attributes.get(PrintQuality.class);
  291.       if (var11 == PrintQuality.DRAFT) {
  292.          this.pageAttributes.setPrintQuality(PrintQualityType.DRAFT);
  293.       } else if (var11 == PrintQuality.HIGH) {
  294.          this.pageAttributes.setPrintQuality(PrintQualityType.HIGH);
  295.       } else {
  296.          this.pageAttributes.setPrintQuality(PrintQualityType.NORMAL);
  297.       }
  298.  
  299.       Media var12 = (Media)this.attributes.get(Media.class);
  300.       if (var12 != null && var12 instanceof MediaSizeName) {
  301.          PageAttributes.MediaType var13 = unMapMedia((MediaSizeName)var12);
  302.          if (var13 != null) {
  303.             this.pageAttributes.setMedia(var13);
  304.          }
  305.       }
  306.  
  307.       this.debugPrintAttributes(false, false);
  308.    }
  309.  
  310.    private void debugPrintAttributes(boolean var1, boolean var2) {
  311.       if (var1) {
  312.          System.out.println("new Attributes\ncopies = " + this.jobAttributes.getCopies() + "\nselection = " + this.jobAttributes.getDefaultSelection() + "\ndest " + this.jobAttributes.getDestination() + "\nfile " + this.jobAttributes.getFileName() + "\nfromPage " + this.jobAttributes.getFromPage() + "\ntoPage " + this.jobAttributes.getToPage() + "\ncollation " + this.jobAttributes.getMultipleDocumentHandling() + "\nPrinter " + this.jobAttributes.getPrinter() + "\nSides2 " + this.jobAttributes.getSides());
  313.       }
  314.  
  315.       if (var2) {
  316.          System.out.println("new Attributes\ncolor = " + this.pageAttributes.getColor() + "\norientation = " + this.pageAttributes.getOrientationRequested() + "\nquality " + this.pageAttributes.getPrintQuality() + "\nMedia2 " + this.pageAttributes.getMedia());
  317.       }
  318.  
  319.    }
  320.  
  321.    private void copyAttributes(PrintService var1) {
  322.       this.attributes = new HashPrintRequestAttributeSet();
  323.       this.attributes.add(new JobName(this.docTitle, (Locale)null));
  324.       PrintService var2 = var1;
  325.       String var3 = this.jobAttributes.getPrinter();
  326.       if (var3 != null && var3 != "" && !var3.equals(var1.getName())) {
  327.          PrintService[] var4 = PrinterJob.lookupPrintServices();
  328.  
  329.          try {
  330.             for(int var5 = 0; var5 < var4.length; ++var5) {
  331.                if (var3.equals(var4[var5].getName())) {
  332.                   this.printerJob.setPrintService(var4[var5]);
  333.                   var2 = var4[var5];
  334.                   break;
  335.                }
  336.             }
  337.          } catch (PrinterException var12) {
  338.          }
  339.       }
  340.  
  341.       JobAttributes.DestinationType var13 = this.jobAttributes.getDestination();
  342.       if (var13 == DestinationType.FILE && var2.isAttributeCategorySupported(Destination.class)) {
  343.          String var14 = this.jobAttributes.getFileName();
  344.          Destination var6;
  345.          if (var14 == null && (var6 = (Destination)var2.getDefaultAttributeValue(Destination.class)) != null) {
  346.             this.attributes.add(var6);
  347.          } else {
  348.             URI var7 = null;
  349.  
  350.             try {
  351.                if (var14 != null) {
  352.                   if (var14.equals("")) {
  353.                      var14 = ".";
  354.                   }
  355.                } else {
  356.                   var14 = "out.prn";
  357.                }
  358.  
  359.                var7 = (new File(var14)).toURI();
  360.             } catch (SecurityException var11) {
  361.                try {
  362.                   var14 = var14.replace('\\', '/');
  363.                   var7 = new URI("file:" + var14);
  364.                } catch (URISyntaxException var10) {
  365.                }
  366.             }
  367.  
  368.             if (var7 != null) {
  369.                this.attributes.add(new Destination(var7));
  370.             }
  371.          }
  372.       }
  373.  
  374.       this.attributes.add(new SunMinMaxPage(this.jobAttributes.getMinPage(), this.jobAttributes.getMaxPage()));
  375.       JobAttributes.SidesType var16 = this.jobAttributes.getSides();
  376.       if (var16 == SidesType.TWO_SIDED_LONG_EDGE) {
  377.          this.attributes.add(Sides.TWO_SIDED_LONG_EDGE);
  378.       } else if (var16 == SidesType.TWO_SIDED_SHORT_EDGE) {
  379.          this.attributes.add(Sides.TWO_SIDED_SHORT_EDGE);
  380.       } else if (var16 == SidesType.ONE_SIDED) {
  381.          this.attributes.add(Sides.ONE_SIDED);
  382.       }
  383.  
  384.       JobAttributes.MultipleDocumentHandlingType var17 = this.jobAttributes.getMultipleDocumentHandling();
  385.       if (var17 == MultipleDocumentHandlingType.SEPARATE_DOCUMENTS_COLLATED_COPIES) {
  386.          this.attributes.add(SheetCollate.COLLATED);
  387.       } else {
  388.          this.attributes.add(SheetCollate.UNCOLLATED);
  389.       }
  390.  
  391.       this.attributes.add(new Copies(this.jobAttributes.getCopies()));
  392.       this.attributes.add(new PageRanges(this.jobAttributes.getFromPage(), this.jobAttributes.getToPage()));
  393.       if (this.pageAttributes.getColor() == ColorType.COLOR) {
  394.          this.attributes.add(Chromaticity.COLOR);
  395.       } else {
  396.          this.attributes.add(Chromaticity.MONOCHROME);
  397.       }
  398.  
  399.       this.pageFormat = this.printerJob.defaultPage();
  400.       if (this.pageAttributes.getOrientationRequested() == OrientationRequestedType.LANDSCAPE) {
  401.          this.pageFormat.setOrientation(0);
  402.          this.attributes.add(OrientationRequested.LANDSCAPE);
  403.       } else {
  404.          this.pageFormat.setOrientation(1);
  405.          this.attributes.add(OrientationRequested.PORTRAIT);
  406.       }
  407.  
  408.       PageAttributes.MediaType var18 = this.pageAttributes.getMedia();
  409.       MediaSizeName var8 = mapMedia(var18);
  410.       if (var8 != null) {
  411.          this.attributes.add(var8);
  412.       }
  413.  
  414.       PageAttributes.PrintQualityType var9 = this.pageAttributes.getPrintQuality();
  415.       if (var9 == PrintQualityType.DRAFT) {
  416.          this.attributes.add(PrintQuality.DRAFT);
  417.       } else if (var9 == PrintQualityType.NORMAL) {
  418.          this.attributes.add(PrintQuality.NORMAL);
  419.       } else if (var9 == PrintQualityType.HIGH) {
  420.          this.attributes.add(PrintQuality.HIGH);
  421.       }
  422.  
  423.    }
  424.  
  425.    public Graphics getGraphics() {
  426.       ProxyPrintGraphics var1 = null;
  427.       synchronized(this) {
  428.          ++this.pageIndex;
  429.          if (this.pageIndex == 0 && !this.graphicsToBeDrawn.isClosed()) {
  430.             this.startPrinterJobThread();
  431.          }
  432.  
  433.          this.notify();
  434.       }
  435.  
  436.       if (this.currentGraphics != null) {
  437.          this.graphicsDrawn.append(this.currentGraphics);
  438.          this.currentGraphics = null;
  439.       }
  440.  
  441.       this.currentGraphics = this.graphicsToBeDrawn.pop();
  442.       if (this.currentGraphics instanceof PeekGraphics) {
  443.          ((PeekGraphics)this.currentGraphics).setAWTDrawingOnly();
  444.          this.graphicsDrawn.append(this.currentGraphics);
  445.          this.currentGraphics = this.graphicsToBeDrawn.pop();
  446.       }
  447.  
  448.       if (this.currentGraphics != null) {
  449.          this.currentGraphics.translate(this.pageFormat.getImageableX(), this.pageFormat.getImageableY());
  450.          double var2 = (double)72.0F / this.getPageResolutionInternal();
  451.          this.currentGraphics.scale(var2, var2);
  452.          var1 = new ProxyPrintGraphics(this.currentGraphics.create(), this);
  453.       }
  454.  
  455.       return var1;
  456.    }
  457.  
  458.    public Dimension getPageDimension() {
  459.       double var1;
  460.       double var3;
  461.       if (this.pageAttributes != null && this.pageAttributes.getOrigin() == OriginType.PRINTABLE) {
  462.          var1 = this.pageFormat.getImageableWidth();
  463.          var3 = this.pageFormat.getImageableHeight();
  464.       } else {
  465.          var1 = this.pageFormat.getWidth();
  466.          var3 = this.pageFormat.getHeight();
  467.       }
  468.  
  469.       double var5 = this.getPageResolutionInternal() / (double)72.0F;
  470.       return new Dimension((int)(var1 * var5), (int)(var3 * var5));
  471.    }
  472.  
  473.    private double getPageResolutionInternal() {
  474.       if (this.pageAttributes != null) {
  475.          int[] var1 = this.pageAttributes.getPrinterResolution();
  476.          return var1[2] == 3 ? (double)var1[0] : (double)var1[0] * 2.54;
  477.       } else {
  478.          return (double)72.0F;
  479.       }
  480.    }
  481.  
  482.    public int getPageResolution() {
  483.       return (int)this.getPageResolutionInternal();
  484.    }
  485.  
  486.    public boolean lastPageFirst() {
  487.       return false;
  488.    }
  489.  
  490.    public synchronized void end() {
  491.       this.graphicsToBeDrawn.close();
  492.       if (this.currentGraphics != null) {
  493.          this.graphicsDrawn.append(this.currentGraphics);
  494.       }
  495.  
  496.       this.graphicsDrawn.closeWhenEmpty();
  497.       if (this.printerJobThread != null && this.printerJobThread.isAlive()) {
  498.          try {
  499.             this.printerJobThread.join();
  500.          } catch (InterruptedException var2) {
  501.          }
  502.       }
  503.  
  504.    }
  505.  
  506.    public void finalize() {
  507.       this.end();
  508.    }
  509.  
  510.    public int print(Graphics var1, PageFormat var2, int var3) throws PrinterException {
  511.       this.graphicsToBeDrawn.append((Graphics2D)var1);
  512.       byte var4;
  513.       if (this.graphicsDrawn.pop() != null) {
  514.          var4 = 0;
  515.       } else {
  516.          var4 = 1;
  517.       }
  518.  
  519.       return var4;
  520.    }
  521.  
  522.    private void startPrinterJobThread() {
  523.       this.printerJobThread = new Thread(this, "printerJobThread");
  524.       this.printerJobThread.start();
  525.    }
  526.  
  527.    public void run() {
  528.       try {
  529.          this.printerJob.print(this.attributes);
  530.       } catch (PrinterException var2) {
  531.       }
  532.  
  533.       this.graphicsToBeDrawn.closeWhenEmpty();
  534.       this.graphicsDrawn.close();
  535.    }
  536.  
  537.    private static int[] getSize(PageAttributes.MediaType var0) {
  538.       int[] var1 = new int[]{612, 792};
  539.  
  540.       for(int var2 = 0; var2 < SIZES.length; ++var2) {
  541.          if (SIZES[var2] == var0) {
  542.             var1[0] = WIDTHS[var2];
  543.             var1[1] = LENGTHS[var2];
  544.             break;
  545.          }
  546.       }
  547.  
  548.       return var1;
  549.    }
  550.  
  551.    public static MediaSizeName mapMedia(PageAttributes.MediaType var0) {
  552.       Object var1 = null;
  553.       int var2 = Math.min(SIZES.length, JAVAXSIZES.length);
  554.  
  555.       for(int var3 = 0; var3 < var2; ++var3) {
  556.          if (SIZES[var3] == var0) {
  557.             if (JAVAXSIZES[var3] != null && MediaSize.getMediaSizeForName(JAVAXSIZES[var3]) != null) {
  558.                var1 = JAVAXSIZES[var3];
  559.             } else {
  560.                var1 = new CustomMediaSizeName(SIZES[var3].toString());
  561.                float var4 = (float)Math.rint((double)WIDTHS[var3] / (double)72.0F);
  562.                float var5 = (float)Math.rint((double)LENGTHS[var3] / (double)72.0F);
  563.                if ((double)var4 > (double)0.0F && (double)var5 > (double)0.0F) {
  564.                   new MediaSize(var4, var5, 25400, (MediaSizeName)var1);
  565.                }
  566.             }
  567.             break;
  568.          }
  569.       }
  570.  
  571.       return (MediaSizeName)var1;
  572.    }
  573.  
  574.    public static PageAttributes.MediaType unMapMedia(MediaSizeName var0) {
  575.       PageAttributes.MediaType var1 = null;
  576.       int var2 = Math.min(SIZES.length, JAVAXSIZES.length);
  577.  
  578.       for(int var3 = 0; var3 < var2; ++var3) {
  579.          if (JAVAXSIZES[var3] == var0 && SIZES[var3] != null) {
  580.             var1 = SIZES[var3];
  581.             break;
  582.          }
  583.       }
  584.  
  585.       return var1;
  586.    }
  587.  
  588.    private void translateInputProps() {
  589.       if (this.props != null) {
  590.          String var1 = this.props.getProperty("awt.print.destination");
  591.          if (var1 != null) {
  592.             if (var1.equals("printer")) {
  593.                this.jobAttributes.setDestination(DestinationType.PRINTER);
  594.             } else if (var1.equals("file")) {
  595.                this.jobAttributes.setDestination(DestinationType.FILE);
  596.             }
  597.          }
  598.  
  599.          var1 = this.props.getProperty("awt.print.printer");
  600.          if (var1 != null) {
  601.             this.jobAttributes.setPrinter(var1);
  602.          }
  603.  
  604.          var1 = this.props.getProperty("awt.print.fileName");
  605.          if (var1 != null) {
  606.             this.jobAttributes.setFileName(var1);
  607.          }
  608.  
  609.          var1 = this.props.getProperty("awt.print.numCopies");
  610.          if (var1 != null) {
  611.             this.jobAttributes.setCopies(Integer.parseInt(var1));
  612.          }
  613.  
  614.          this.options = this.props.getProperty("awt.print.options", "");
  615.          var1 = this.props.getProperty("awt.print.orientation");
  616.          if (var1 != null) {
  617.             if (var1.equals("portrait")) {
  618.                this.pageAttributes.setOrientationRequested(OrientationRequestedType.PORTRAIT);
  619.             } else if (var1.equals("landscape")) {
  620.                this.pageAttributes.setOrientationRequested(OrientationRequestedType.LANDSCAPE);
  621.             }
  622.          }
  623.  
  624.          var1 = this.props.getProperty("awt.print.paperSize");
  625.          if (var1 != null) {
  626.             if (var1.equals("letter")) {
  627.                this.pageAttributes.setMedia(SIZES[MediaType.LETTER.hashCode()]);
  628.             } else if (var1.equals("legal")) {
  629.                this.pageAttributes.setMedia(SIZES[MediaType.LEGAL.hashCode()]);
  630.             } else if (var1.equals("executive")) {
  631.                this.pageAttributes.setMedia(SIZES[MediaType.EXECUTIVE.hashCode()]);
  632.             } else if (var1.equals("a4")) {
  633.                this.pageAttributes.setMedia(SIZES[MediaType.A4.hashCode()]);
  634.             }
  635.          }
  636.  
  637.       }
  638.    }
  639.  
  640.    private void translateOutputProps() {
  641.       if (this.props != null) {
  642.          this.props.setProperty("awt.print.destination", this.jobAttributes.getDestination() == DestinationType.PRINTER ? "printer" : "file");
  643.          String var1 = this.jobAttributes.getPrinter();
  644.          if (var1 != null && !var1.equals("")) {
  645.             this.props.setProperty("awt.print.printer", var1);
  646.          }
  647.  
  648.          var1 = this.jobAttributes.getFileName();
  649.          if (var1 != null && !var1.equals("")) {
  650.             this.props.setProperty("awt.print.fileName", var1);
  651.          }
  652.  
  653.          int var2 = this.jobAttributes.getCopies();
  654.          if (var2 > 0) {
  655.             this.props.setProperty("awt.print.numCopies", "" + var2);
  656.          }
  657.  
  658.          var1 = this.options;
  659.          if (var1 != null && !var1.equals("")) {
  660.             this.props.setProperty("awt.print.options", var1);
  661.          }
  662.  
  663.          this.props.setProperty("awt.print.orientation", this.pageAttributes.getOrientationRequested() == OrientationRequestedType.PORTRAIT ? "portrait" : "landscape");
  664.          PageAttributes.MediaType var3 = SIZES[this.pageAttributes.getMedia().hashCode()];
  665.          if (var3 == MediaType.LETTER) {
  666.             var1 = "letter";
  667.          } else if (var3 == MediaType.LEGAL) {
  668.             var1 = "legal";
  669.          } else if (var3 == MediaType.EXECUTIVE) {
  670.             var1 = "executive";
  671.          } else if (var3 == MediaType.A4) {
  672.             var1 = "a4";
  673.          } else {
  674.             var1 = var3.toString();
  675.          }
  676.  
  677.          this.props.setProperty("awt.print.paperSize", var1);
  678.       }
  679.    }
  680.  
  681.    private void throwPrintToFile() {
  682.       SecurityManager var1 = System.getSecurityManager();
  683.       FilePermission var2 = null;
  684.       if (var1 != null) {
  685.          if (var2 == null) {
  686.             var2 = new FilePermission("<<ALL FILES>>", "read,write");
  687.          }
  688.  
  689.          var1.checkPermission(var2);
  690.       }
  691.  
  692.    }
  693.  
  694.    static {
  695.       SIZES = new PageAttributes.MediaType[]{MediaType.ISO_4A0, MediaType.ISO_2A0, MediaType.ISO_A0, MediaType.ISO_A1, MediaType.ISO_A2, MediaType.ISO_A3, MediaType.ISO_A4, MediaType.ISO_A5, MediaType.ISO_A6, MediaType.ISO_A7, MediaType.ISO_A8, MediaType.ISO_A9, MediaType.ISO_A10, MediaType.ISO_B0, MediaType.ISO_B1, MediaType.ISO_B2, MediaType.ISO_B3, MediaType.ISO_B4, MediaType.ISO_B5, MediaType.ISO_B6, MediaType.ISO_B7, MediaType.ISO_B8, MediaType.ISO_B9, MediaType.ISO_B10, MediaType.JIS_B0, MediaType.JIS_B1, MediaType.JIS_B2, MediaType.JIS_B3, MediaType.JIS_B4, MediaType.JIS_B5, MediaType.JIS_B6, MediaType.JIS_B7, MediaType.JIS_B8, MediaType.JIS_B9, MediaType.JIS_B10, MediaType.ISO_C0, MediaType.ISO_C1, MediaType.ISO_C2, MediaType.ISO_C3, MediaType.ISO_C4, MediaType.ISO_C5, MediaType.ISO_C6, MediaType.ISO_C7, MediaType.ISO_C8, MediaType.ISO_C9, MediaType.ISO_C10, MediaType.ISO_DESIGNATED_LONG, MediaType.EXECUTIVE, MediaType.FOLIO, MediaType.INVOICE, MediaType.LEDGER, MediaType.NA_LETTER, MediaType.NA_LEGAL, MediaType.QUARTO, MediaType.A, MediaType.B, MediaType.C, MediaType.D, MediaType.E, MediaType.NA_10X15_ENVELOPE, MediaType.NA_10X14_ENVELOPE, MediaType.NA_10X13_ENVELOPE, MediaType.NA_9X12_ENVELOPE, MediaType.NA_9X11_ENVELOPE, MediaType.NA_7X9_ENVELOPE, MediaType.NA_6X9_ENVELOPE, MediaType.NA_NUMBER_9_ENVELOPE, MediaType.NA_NUMBER_10_ENVELOPE, MediaType.NA_NUMBER_11_ENVELOPE, MediaType.NA_NUMBER_12_ENVELOPE, MediaType.NA_NUMBER_14_ENVELOPE, MediaType.INVITE_ENVELOPE, MediaType.ITALY_ENVELOPE, MediaType.MONARCH_ENVELOPE, MediaType.PERSONAL_ENVELOPE};
  696.       JAVAXSIZES = new MediaSizeName[]{null, null, MediaSizeName.ISO_A0, MediaSizeName.ISO_A1, MediaSizeName.ISO_A2, MediaSizeName.ISO_A3, MediaSizeName.ISO_A4, MediaSizeName.ISO_A5, MediaSizeName.ISO_A6, MediaSizeName.ISO_A7, MediaSizeName.ISO_A8, MediaSizeName.ISO_A9, MediaSizeName.ISO_A10, MediaSizeName.ISO_B0, MediaSizeName.ISO_B1, MediaSizeName.ISO_B2, MediaSizeName.ISO_B3, MediaSizeName.ISO_B4, MediaSizeName.ISO_B5, MediaSizeName.ISO_B6, MediaSizeName.ISO_B7, MediaSizeName.ISO_B8, MediaSizeName.ISO_B9, MediaSizeName.ISO_B10, MediaSizeName.JIS_B0, MediaSizeName.JIS_B1, MediaSizeName.JIS_B2, MediaSizeName.JIS_B3, MediaSizeName.JIS_B4, MediaSizeName.JIS_B5, MediaSizeName.JIS_B6, MediaSizeName.JIS_B7, MediaSizeName.JIS_B8, MediaSizeName.JIS_B9, MediaSizeName.JIS_B10, MediaSizeName.ISO_C0, MediaSizeName.ISO_C1, MediaSizeName.ISO_C2, MediaSizeName.ISO_C3, MediaSizeName.ISO_C4, MediaSizeName.ISO_C5, MediaSizeName.ISO_C6, null, null, null, null, MediaSizeName.ISO_DESIGNATED_LONG, MediaSizeName.EXECUTIVE, MediaSizeName.FOLIO, MediaSizeName.INVOICE, MediaSizeName.LEDGER, MediaSizeName.NA_LETTER, MediaSizeName.NA_LEGAL, MediaSizeName.QUARTO, MediaSizeName.A, MediaSizeName.B, MediaSizeName.C, MediaSizeName.D, MediaSizeName.E, MediaSizeName.NA_10X15_ENVELOPE, MediaSizeName.NA_10X14_ENVELOPE, MediaSizeName.NA_10X13_ENVELOPE, MediaSizeName.NA_9X12_ENVELOPE, MediaSizeName.NA_9X11_ENVELOPE, MediaSizeName.NA_7X9_ENVELOPE, MediaSizeName.NA_6X9_ENVELOPE, MediaSizeName.NA_NUMBER_9_ENVELOPE, MediaSizeName.NA_NUMBER_10_ENVELOPE, MediaSizeName.NA_NUMBER_11_ENVELOPE, MediaSizeName.NA_NUMBER_12_ENVELOPE, MediaSizeName.NA_NUMBER_14_ENVELOPE, null, MediaSizeName.ITALY_ENVELOPE, MediaSizeName.MONARCH_ENVELOPE, MediaSizeName.PERSONAL_ENVELOPE};
  697.       WIDTHS = new int[]{4768, 3370, 2384, 1684, 1191, 842, 595, 420, 298, 210, 147, 105, 74, 2835, 2004, 1417, 1001, 709, 499, 354, 249, 176, 125, 88, 2920, 2064, 1460, 1032, 729, 516, 363, 258, 181, 128, 91, 2599, 1837, 1298, 918, 649, 459, 323, 230, 162, 113, 79, 312, 522, 612, 396, 792, 612, 612, 609, 612, 792, 1224, 1584, 2448, 720, 720, 720, 648, 648, 504, 432, 279, 297, 324, 342, 360, 624, 312, 279, 261};
  698.       LENGTHS = new int[]{6741, 4768, 3370, 2384, 1684, 1191, 842, 595, 420, 298, 210, 147, 105, 4008, 2835, 2004, 1417, 1001, 729, 499, 354, 249, 176, 125, 4127, 2920, 2064, 1460, 1032, 729, 516, 363, 258, 181, 128, 3677, 2599, 1837, 1298, 918, 649, 459, 323, 230, 162, 113, 624, 756, 936, 612, 1224, 792, 1008, 780, 792, 1224, 1584, 2448, 3168, 1080, 1008, 936, 864, 792, 648, 648, 639, 684, 747, 792, 828, 624, 652, 540, 468};
  699.    }
  700. }
  701.